home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 114 / CDRom114.iso / internet / extens / tcopy / Copy Plain Text.xpi / install.js next >
Encoding:
Text File  |  2004-11-10  |  1.6 KB  |  53 lines

  1.  
  2. const gName            = "CopyPlainText";
  3. const gAuthor        = "Jeremy Gillick";
  4. const gRegKey        = "/JeremyGillick/CopyPlainText";
  5. const gVersion        = "0.2";
  6. const gJar            = "copyplaintext.jar";
  7.  
  8. var    error             = null;
  9. var oFolder            = getFolder("Current User", "chrome");
  10. var iContentFlag    = CONTENT | PROFILE_CHROME;
  11.  
  12. // Install in App or Profile?
  13. var existsInApplication = File.exists(getFolder(getFolder("chrome"), gJar));
  14. var existsInProfile     = File.exists(getFolder(oFolder, gJar));
  15. if(existsInApplication || (!existsInProfile && !confirm("Do you want to install the extension into your profile folder?\n(Cancel will install into the application folder)")))
  16. {
  17.     iContentFlag = CONTENT | DELAYED_CHROME;
  18.     oFolder      = getFolder("chrome");
  19. }
  20.  
  21. // Uninstall Current
  22. if(existsInApplication || existsInProfile)
  23.     uninstall(gRegKey);
  24.  
  25. // Init
  26. initInstall(gName, gRegKey, gVersion);
  27. setPackageFolder(oFolder);
  28. error = addFile(gAuthor, gVersion, "chrome/"+ gJar, oFolder, null);
  29.  
  30. // Register
  31. if(error == SUCCESS){
  32.     registerChrome(iContentFlag, getFolder(oFolder, gJar), "content/");
  33.     
  34.     error = performInstall(); //Install
  35.     
  36.     if(error != SUCCESS && error != 999){
  37.         switch(error){
  38.             case -215:
  39.                 alert("The installation of the extension failed.\nOne of the files being overwritten is read-only.");
  40.                 break;
  41.             case -235:
  42.                    alert("The installation of the extension failed.\nThere is insufficient disk space.");
  43.                 break;
  44.             default: 
  45.                 alert("The installation of the extension failed.\nThe error code is: " + error);
  46.         }
  47.         cancelInstall(error);
  48.     }
  49. }
  50. else{
  51.     alert("The installation failed.\n" + error);
  52.     cancelInstall(error);
  53. }